<?php
use Illuminate\Database\Eloquent\SoftDeletingTrait;

class Item extends Eloquent {
	use SoftDeletingTrait;

	protected $table="items";
	protected $primaryKey = "pk";
	protected $fillable = [];
    protected $dates = ['deleted_at'];


	public function user()
	{
		return $this->belongsTo('User', 'created_by_fk', 'pk');
	}

	public function itemLocation()
	{
		return $this->belongsTo('ItemLocation', 'located_at_fk', 'pk');
	}

	public function requests()
	{
		return $this->hasMany('ItemRequestItem', 'item_fk', 'pk');
	}

	public function formattedPrice()
	{
		return sprintf("COP %s", number_format($this->price));
	}
}

?>